//
//  KABExhDetBuyTCell.m
//  kabu
//
//  Created by XiangDongMBP on 2017/3/7.
//  Copyright © 2017年 East. All rights reserved.
//

#import "KABExhDetBuyTCell.h"
#import "KABModel.h"
#import "GlobalHeader.h"
#import "UIColor+XDHex.h"

@implementation KABExhDetBuyTCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    self.buyBtn.layer.masksToBounds = YES;
    self.buyBtn.layer.cornerRadius = CGRectGetHeight(self.buyBtn.bounds) / 2.0;
    [self.buyBtn addTarget:self action:@selector(buyBtnTapped:) forControlEvents:UIControlEventTouchUpInside];
    
    self.followBtn.layer.masksToBounds = YES;
    self.followBtn.layer.cornerRadius = CGRectGetHeight(self.followBtn.bounds) / 2.0;
    [self.followBtn addTarget:self action:@selector(followBtnTapped:) forControlEvents:UIControlEventTouchUpInside];
}

- (void)buyBtnTapped:(UIButton *)btn {
    if ([self.delegate respondsToSelector:@selector(kABExhDetBuyTCell:buyBtnTapped:)]) {
        [self.delegate kABExhDetBuyTCell:self buyBtnTapped:btn];
    }
}

- (void)followBtnTapped:(UIButton *)btn {
    if ([self.delegate respondsToSelector:@selector(kABExhDetBuyTCell:followBtnTapped:)]) {
        [self.delegate kABExhDetBuyTCell:self followBtnTapped:btn];
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)configViewWithExhListItem:(KABExhListItem *)item {
    self.followBtn.selected = item.is_collected;
    
    if (item.is_buyable) {
        self.buyBtn.backgroundColor = [UIColor xd_colorWithHex:KABGlobalColorTabBarItemColor];
    } else {
        self.buyBtn.backgroundColor = [UIColor xd_colorWithHex:0xD8D8D8];
    }
}

@end
